package com.zjw.socket.demo.starter.messageService;

import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

public class User {

  public String name;

  public boolean sex = false;

  public String imageUrl;

  public String phone;

  public long username;

  public String password;

  public String address;

  public String signature;

  public List<UserFriend> friends = new ArrayList<>();


  @Override
  public boolean equals(Object o) {
    if (this == o) return true;
    if (!(o instanceof User)) return false;
    User user = (User) o;
    return username == user.username;
  }

  @Override
  public int hashCode() {
    return Objects.hash(username);
  }

  public SimpleUser toSimpleUser() {
    SimpleUser simpleUser = new SimpleUser();
    simpleUser.imageUrl = this.imageUrl;
    simpleUser.sex = this.sex;
    simpleUser.phone = this.phone;
    simpleUser.name = this.name;
    simpleUser.username = this.username;
    simpleUser.address = this.address;
    simpleUser.signature = this.signature;
    return simpleUser;
  }

  public UserFriend toFriend(long meetTime) {
    UserFriend friend = new UserFriend();
    friend.imageUri = this.imageUrl;
    friend.sex = this.sex;
    friend.phone = this.phone;
    friend.name = this.name;
    friend.username = this.username;
    friend.meetTime = meetTime;
    friend.assignName = this.name;
    return friend;
  }
}
